using Cysharp.Threading.Tasks;
using MoonFramework.View;
using Tool.Name;

namespace MoonFramework.FSM
{
    public abstract class WalkState : BaseState
    {
        protected bool _isRun;
        protected int index;

        public override void Enter()
        {
            _isRun = true;
            AnimancerManager.Instance.Play(_actor.viewController._WalkAnimation, _actor.viewController.AnimancerComponent);
            _actor.viewController.AddAnimationEvent(nameof(FootStep), FootStep);
            Walk().Forget();
        }

        protected abstract UniTaskVoid Walk();

        public override void Exit()
        {
            _isRun = false;
            _actor.viewController.RemoveAnimationEvent(nameof(FootStep), FootStep);
        }
        
        //向动画组件发送帧事件
        protected abstract void FootStep();
    }
}